package com.wgchao.identityrightsmanagement.infrastructure.convert;

import com.wgchao.identityrightsmanagement.domain.organization.model.Department;
import com.wgchao.identityrightsmanagement.infrastructure.jpa.entity.SysBaseDepartment;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @ClassName: DepartmentConvert
 * @author: wgchao
 * @createTime: 2020/6/15 5:36 PM
 * @Description: TODO
 */
@Component
public class DepartmentConvert {

    public Department convert(SysBaseDepartment sysBaseDepartment){
        return new Department(sysBaseDepartment.getId(), sysBaseDepartment.getCode(), sysBaseDepartment.getName(), sysBaseDepartment.getAgencyCode(),
                sysBaseDepartment.getDescription(), sysBaseDepartment.isDisabled(), sysBaseDepartment.getVersion());
    }

    public SysBaseDepartment convert(Department department){
        SysBaseDepartment sysBaseDepartment = new SysBaseDepartment();
        BeanUtils.copyProperties(department, sysBaseDepartment);
        return sysBaseDepartment;
    }
}
